#!/usr/bin/env bash

if [[ -z "$1" ]]; then
  echo "no domain in first position. renew_tls failing"
  exit 1
fi

if [[ -z "$2" ]]; then
  echo "no user in second position. renew_tls failing"
  exit 1
fi

sudo cp ./deploy-scripts/renew_tls.sh /root/renew_tls.sh
# add our job to crontab if it's not there already
(sudo crontab -l | grep "renew_tls.sh $1") || ( sudo crontab -l; echo "0 12 * * * /root/renew_tls.sh $1 $2"; ) | sudo crontab

